package com.planet.biz;

import com.planet.db.dao.CheckUserMapper;
import com.planet.db.model.CheckUser;
import com.planet.facade.CheckUserBiz;
import com.planet.query.CheckUserQuery;
import com.planet.utils.CommonConverter;
import com.planet.vo.CheckUserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jiayazi on 17/11/15.
 */
@Component("checkUserBiz")
public class CheckUserBizImpl implements CheckUserBiz{

    @Autowired
    CheckUserMapper checkUserMapper;

    @Override
    public boolean insertCheckInfo(CheckUserQuery checkUserQuery) {
        return checkUserMapper.insertSelective(checkUserQuery);
    }

    @Override
    public CheckUserVO getCheckInfo(String phone) {
        CheckUser checkUser = checkUserMapper.getCheckInfo(phone);
        CheckUserVO checkUserVO = new CheckUserVO();
        CommonConverter.convert(checkUser,checkUserVO);
        return checkUserVO;
    }

    @Override
    public List<CheckUserVO> getCheckList() {
        List<CheckUser> checkUsers = checkUserMapper.getCheckList();
        List<CheckUserVO> checkUserVOS = new ArrayList<>(checkUsers.size());
        CommonConverter.convertList(CheckUserVO.class,checkUsers,checkUserVOS);
        return checkUserVOS;
    }



}
